package br.com.ufpr.sgp.pages;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.request.cycle.RequestCycle;
import org.wicketstuff.annotation.mount.MountPath;

import br.com.ufpr.sgp.WicketApplication;
import br.com.ufpr.sgp.util.session.CustomSession;
import br.com.ufpr.sgp.util.session.CustomSessionProvider;


@MountPath("Logout")
public class LogoutPage extends WebPage {
    private static final long serialVersionUID = 5079314115947629662L;

    public LogoutPage() {

    	WicketApplication
                .get()
                .getCookieService()
                .removeCookieIfPresent(RequestCycle.get().getRequest(), RequestCycle.get().getResponse(),
                        CustomSessionProvider.REMEMBER_ME_LOGIN_COOKIE);
    	WicketApplication
                .get()
                .getCookieService()
                .removeCookieIfPresent(RequestCycle.get().getRequest(), RequestCycle.get().getResponse(),
                        CustomSessionProvider.REMEMBER_ME_PASSWORD_COOKIE);

        CustomSession.get().setUsuario(null);
        CustomSession.get().invalidate();

        setResponsePage(WicketApplication.get().getHomePage());
    }

}
